/*
 * log.h
 *
 *  Created on: 2024-01-18
 *      Author: liaofd
 */

#include "log.h"
#include "main.h"

static log_level_t	log_level = LOG_INFO;
static int log_shell_keep_seconds = 0;

int is_app_direct_call_printf_disable(void)
{
	return log_level == LOG_PRINTF_DISABLE;
}

void set_log_level(log_level_t lv, int sec)
{
	log_level = lv;
	if(log_level == LOG_SHELL)
		log_shell_keep_seconds = sec;
}

int is_log_shell_keep_active(void)
{
	return log_shell_keep_seconds;
}

void log_shell_keep_time_handler(void)
{
	static uint32_t time_backup;
	uint32_t tick = HAL_GetTick();
	if(tick - time_backup >= 1000)
	{
		time_backup = tick;
		if(log_shell_keep_seconds)
		{
			log_shell_keep_seconds--;
		}
	}
}
